<html>
<head>
    <title>内置服务，网络请求$http</title>
    <script type="text/javascript" src="../plugins/angularjs/angular.min.js"></script>
    <meta charset="utf-8"/>
    <script>
        //定义模块
        var appArr = angular.module('myArr', []);
        appArr.controller('myArrController', function ($scope, $http) {

            //定义从访问网络的方法
            $scope.allUser = function () {

                //定义封装ajax,此处模仿网络请求
                $http.get('user.json').success(
                    function (response) {
                        //返回值就是json
                        $scope.users = response;
                    }
                );
            }
        });
    </script>
</head>

<!--ng-init 页面初始化完毕就调用方法-->
<body ng-app="myArr" ng-controller="myArrController" ng-init="allUser()">
<h2>内置服务，网络请求$http</h2>
<table>
    <thead>
    <td>姓名</td>
    <td>年龄</td>
    <td>地址</td>
    </thead>
    <tr ng-repeat="user in users">
        <td>{{user.name}}</td>
        <td>{{user.age}}</td>
        <td>{{user.address}}</td>
    </tr>
</table>
</body>
</html>
